﻿$(function () {
					var chartAreaSpLine;
					$(document).ready(function() {
						chartAreaSpLine = new Highcharts.Chart({
							chart: {
								renderTo: 'graphTabAreaSPLine',
								marginRight:40,
								borderColor: '#EBBA95',
								type: 'areaspline'
							},
							title: {
									text: '',
							},
							credits: {
									text: 'www.logica.fr',
									href: 'http://www.logica.fr/',
									position: {
										align: 'right',
										x: -30
									}
							},
							legend: {
									backgroundColor: '#FFFFFF'
							},
							 xAxis: {
								title: {
									enabled: true,
									text: '<b>Année</b>',
									margin: 10,
									style: {
										fontWeight: 'normal'
									}
								},
								categories: years,
								
								labels: {
										rotation: -45,
										align: 'right',
										style: {
											fontSize: '10px',
											fontFamily: 'Verdana, sans-serif'
										}
									}
							 },
							 yAxis: {
									min: 0,
									title: {
									   text: 'Nombre de faits'
									}
							},
							tooltip: {
										crosshairs: true,
										shared: true
										
								},
								  plotOptions: {
										areaspline: {
											fillOpacity: 0.3
										}
									},
							 series: [{
									id: 'Tous',
									name: 'Tous',
									data: getValueBydepartments("Tous")
								 }]
						});
						for(var $i = 0 ;$i < departments.length ; $i++ ){
								$("#listCheckboxSPArea").append("<li><input type='checkbox' name='"+departments[$i]+"' id='"+departments[$i]+"' class='custom' /><label for ='"+departments[$i]+"'>"+departments[$i]+"</label></li>");
						}
						$("#listCheckboxSPArea input[name='Tous']").attr("checked","checked");
						$("#listCheckboxSPArea input[type='checkbox']").bind( "change", function(event, ui) {
						if($(this).is(':checked')){
							chartAreaSpLine.addSeries({id: $(this).attr("name"),name:$(this).attr("name"),data: getValueBydepartments($(this).attr("name"))});
						}else{
							chartAreaSpLine.get($(this).attr("name")).remove();
						}
					 });
					});
					
					
				});
				
			